package com.swufestu.second;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class MyAdapter extends ArrayAdapter {
    private static final String TAG = "MyAdapter";

    public MyAdapter(Context context, int resource, ArrayList<HashMap<String,String>> list){
        super(context,resource,list);
    }

    public View getView(int position, View convertView, ViewGroup parent){
        View itemView = convertView;
        if(itemView == null){
            itemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item,parent,false);
        }

        Map<String,String > map = (Map<String,String >) getItem(position);
        TextView country = (TextView) itemView.findViewById(R.id.country);
        TextView rate = (TextView) itemView.findViewById(R.id.rate);

        country.setText("country："+map.get("country"));
        rate.setText("rate:"+map.get("rate"));

        return itemView;
    }

}
